import request from '@/router/axios';

/**
 * 服务器设置
 *   发送:1
 *   接受：0
 * */
//获取类型URL
function getURL(type) {
  return type == 1 ? 'smtp' : 'pop3';
}
//查询
export const query = (type) => {
  return request({
    url: `/api/blade-email/${getURL(type)}`,
    method: 'get'
  })
}
//查询社交账号
export const getSocialAccount = () => {
  return request({
    url: '/api/blade-social/socialAccount/platform/accounts',
    method: 'get'
  })
}
//添加
export const add = (row,type) => {
  return request({
    url: `/api/blade-email/${getURL(type)}`,
    method: 'post',
    headers: {
      "Content-Type": "application/json"
    },
    data: JSON.stringify(row)
  })
}
//修改
export const update = (row,type) => {
  return request.put(`/api/blade-email/${getURL(type)}`, row)
}
//删除
export const del = (id,type) => {
  return request.delete(`/api/blade-email/${getURL(type)}/${id}`, {params: {id: id}})
}
//设置默认
export const setDefault = (id) => {
  return request.put(`/api/blade-email/smtp/${id}/default`, {id: id})
}

//备份
export const backup = (id) => {
  return request.put(`/api/blade-email/pop3/${id}/backup`, {id:id})
}
//转移
export const move = (id) => {
  return request.put(`/api/blade-email/pop3/${id}/move`, {id:id})
}


//社交解绑
export const unbindingAccounts = (id) => {
  return request({
    url: `/api/blade-social/socialAccount/${id}`,
    method: 'delete'
  })
}
//检测邮箱
export const checkEmail = (email) => {
  return request({
    url: `/api/blade-email/smtp/detection/${email}`,
    method: 'post'
  })
}
